package com.spider.spiderorderbasedata.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spider.spiderorderbasedata.mapper.DataPeopleMapper;
import com.spider.spiderorderbasedata.model.entity.DataPeople;
import com.spider.spiderorderbasedata.service.DataPeopleService;
import org.springframework.stereotype.Service;

/**
 * @author xiong.bo
 * @version 1.0
 * @date 2024/5/10 8:20 下午
 */

@Service
public class DataPeopleServiceImpl extends ServiceImpl<DataPeopleMapper, DataPeople>
        implements DataPeopleService {

    @Override
    public IPage<DataPeople> selectPage(int page, int pageSize) {
        Page<DataPeople> pageObject = new Page(page, pageSize);
        LambdaQueryWrapper<DataPeople> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(DataPeople::getCreateTime);
        return this.baseMapper.selectPage(pageObject, queryWrapper);
    }

    @Override
    public DataPeople findById(Long id) {
        return this.getById(id);
    }

    @Override
    public DataPeople saveDataPeople(DataPeople dataPeople) {
        this.save(dataPeople);
        return dataPeople;
    }

    @Override
    public DataPeople editDataPeople(DataPeople dataPeople) {
        this.updateById(dataPeople);
        return dataPeople;
    }

    @Override
    public Boolean deleteDataPeople(Long id) {
        return removeById(id);
    }
}
